package com.qf.handlerException;

import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


/**
 * 异常处理器
 * 捕获所有异常统一处理
 */
public class MyHandlerException implements HandlerExceptionResolver {
    @Override
    public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
//        打印异常堆栈信息
        ex.printStackTrace();
        ModelAndView mv = new ModelAndView();
        mv.addObject("errorMsg","系统异常");
        mv.setViewName("/error.jsp");
        return mv;
    }
}
